#include<iostream>
#include<jsoncpp/json/json.h>
#include<unistd.h>

int main(){
    Json::Value part1;
    part1["haha"] = "haha";
    part1["hehe"] = "hehe";
    
    Json::Value root;
    root["x"]=100;
    root["y"]=200;
    root["op"]='+';
    root["desc"] = "this is a + open";
    root["test"] = part1;

    // Json::StyledWriter  w;
    Json::FastWriter  w;

    std::string res = w.write(root);//序列化？
    std::cout<<res<<std::endl;

    sleep(3);
    
    Json::Value v;
    Json::Reader r;//反序列化
    r.parse(res,v);//
    
    int x = v["x"].asInt();
    int y = v["y"].asInt();
    char op = v["op"].asInt();
    std::string desc = v["desc"].asString();
    Json::Value temp = v["test"];
    std::cout<< x << std::endl;
    std::cout<< y << std::endl;
    std::cout<< op <<std::endl;
    std::cout<< desc<<std::endl;
}